package com.topfinance.cnaps2.service.impl;

import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeanUtils;

import com.topfinance.cnaps2.dto.TblTxDetailDto;
import com.topfinance.cnaps2.ebo.TblTxDetailEbo;
import com.topfinance.cnaps2.service.ITblTxDetailManager;
import com.topfinance.frame.dao.HibernateEntityDao;
import com.topfinance.frame.exception.AppException;
import com.topfinance.frame.util.StringUtil;

/**
 * 该类自动实现了dao的一般方法，如add, remove, update
 * 在service中出现的大部分情况下是在向后台提交数据前的处理(如校验)及获取后台数据后的处理等
 * @author
 *
 */

public class TblTxDetailManagerImpl extends HibernateEntityDao<TblTxDetailEbo> implements ITblTxDetailManager {

	private static final Log log = LogFactory.getLog(TblTxDetailManagerImpl.class);

	public void addTblTxDetail(TblTxDetailEbo o) throws AppException{
    	save(o);
    }
	
	public void editTblTxDetail(TblTxDetailEbo o) throws AppException{
		// 删除原始传输协议和部门映射
		//CfgTxDetailPortInfoEbo user = get(o.getUserId());
		//deleteDepartUserMap(o.getUserId());
		//flush();
		//clear();
		// 保存传输协议
    	saveOrUpdate(o);
    	//save(sysDepartmentUserMapEbo);
    }
	
	//获得传输协议	
	public TblTxDetailEbo getTblTxDetail(String uid) throws AppException{
		return (TblTxDetailEbo)get(uid);
	}

	public void deleteTblTxDetail(TblTxDetailEbo o) throws AppException{
		removeById(o.getClass(),o.getUId());
    }

	//获得传输协议列表
	public List getAllTblTxDetailList(String auid) throws AppException{
		String hql = " from TblTxDetailEbo t where t.auditId = '" +  auid + "'";
		List list = find(hql);
		int size = list.size();
		for(int i=0;i<size;i++){
			TblTxDetailEbo tx = (TblTxDetailEbo)list.get(i);
			TblTxDetailDto t = new TblTxDetailDto();
			BeanUtils.copyProperties(tx, t);
			t.setTsEx(StringUtil.convertDate(tx.getTs()));
			list.set(i, t);
		}
		return list;
	}
}
